import SceneManager from "../../manager/SceneManager";
import CallModel from "../../model/CallModel";
import CallSuccess from "./CallSuccess";


const {ccclass, property} = cc._decorator;

@ccclass
export default class CallMenu extends cc.Component {

    @property(cc.Node)
    success: cc.Node = null;
    @property(cc.Node)
    HeroMessage: cc.Node = null;
    @property(cc.Node)
    call0: cc.Node = null;
    @property(cc.Node)
    call1: cc.Node = null;
    @property(cc.Node)
    call2: cc.Node = null;
    @property(cc.Node)
    call3: cc.Node = null;


    private call(){
        this.success.active = true;
        this.node.active = false;
    }
    private callZero(){
        CallModel.instance.actionEnterCallResult(0,this.call.bind(this))
    }
    private callOne(){
        CallModel.instance.actionEnterCallResult(1,this.call.bind(this))
    }
    private callTwo(){
        CallModel.instance.actionEnterCallResult(2,this.call.bind(this))
    }
    private callThree(){
        CallModel.instance.actionEnterCallResult(3,this.call.bind(this))
    }
    private return(){
        SceneManager.instance.goto('MainScene');
    }
    
    // LIFE-CYCLE CALLBACKS:

    onLoad () {
        
    }

    start () {
        this.success.active = false;
        this.HeroMessage.active = false;
    }

    update (dt) {       
        if(this.call0.x>=288){
            this.call0.x -= 250*dt;
        }
        if(this.call1.x>=288){
            this.call1.x -= 260*dt;
        }
        if(this.call2.x>=288){
            this.call2.x -= 270*dt;
        }
        if(this.call3.x>=288){
            this.call3.x -= 280*dt;
        }
    }
}
